/** BusinessObject.java
 */

package edu.byu.isys413.group1E.data;

/**
 * The super-class of most business objects in the program.
 *
 * @author Conan C. Albrecht
 */
public abstract class BusinessObject {
    
    boolean alreadyInDB = false;
    private String id = null;
    private boolean isDirty = false;
    
    /** Creates a new instance of BusinessObject */
    public BusinessObject() {
    }//constructor
    
    /** Returns the business object's id
     * 
     * @return id
     */
    public String getId() {
        return id;
    }
    
    /** Sets the business object's id
     * 
     * @param id contains the id for the business object
     */
    public void setId(String id) {
        this.setIsDirty(true);
        this.id = id;
    }
    
    /** Returns if the business object has already been saved to the database
     * 
     * @return alreadyInDB
     */
    public boolean isAlreadyInDB() {
        return alreadyInDB;
    }
    
    /** Sets if the business object has already been saved to the database.
     * 
     * @param alreadyInDB indicates if the object has already been saved to the DB.
     */
    public void setAlreadyInDB(boolean alreadyInDB) {
        this.setIsDirty(true);
        this.alreadyInDB = alreadyInDB;
    }
    
    /** Indicates if information has changed.
     * 
     * @return isDirty
     */
    public boolean isIsDirty() {
        return isDirty;
    }
    
    /** Sets if information has changed in the business object.
     * 
     * @param isDirty indicates if info has changed.
     */
    public void setIsDirty(boolean isDirty) {
        this.isDirty = isDirty;
    }
    
    /** A duplicate method with another name for setIsdirty()
     */
    public void soil() {
        this.isDirty = true;
    }
    
    /** Sets the isDirty variable to false, to indicate that the object's changes have been saved.
     */
    public void clean() {
        this.isDirty = false;
    }
    
}//class
